<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/public/head.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script type="text/javascript">
        $(function(){
            var arr='${menus}';
            $('#tt').tree({
                data:JSON.parse(arr),
                checkbox:true
            });
		});

         //保存
        function save(){
            var nodes = $('#tt').tree('getChecked','indeterminate');
            alert(nodes.length);
            var data=[];
            for (var i = 0; i < nodes.length; i++) {
                var val={"rid":"${roleid}"*1,"mid":nodes[i].id};
                data.push(val)
            }
             parent.initialize();
            $.ajax({
                type: "post",
                data: JSON.stringify(data),
                url: "${system}/role/authmenus",
                dataType: "json",
                contentType:"application/json", // 指定这个协议很重要 k:v 表单域   key:val&key:val    json:{key:val}
                success: function(data){
                    parent.subSomething();
                    parent.message_alert(data);
                    parent.closemodalwindow();
                }
            });

        }
 
</script>
</head>
<body>
<div>
	<ul id="tt"></ul>
      <br><br>
    <a id="submitbtn"  class="easyui-linkbutton"   iconCls="icon-ok" href="#" onclick="save()">提交</a>
</div>
</body>
</html>